package cn.iocoder.yudao.module.member.dal.mysql.memberconf.confmaterial;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.confmaterial.vo.MemberConfMaterialPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.memberconf.confmaterial.MemberConfMaterialDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 物料策略配置 Mapper
 *
 * @author doock
 */
@Mapper
public interface MemberConfMaterialMapper extends BaseMapperX<MemberConfMaterialDO> {

    default PageResult<MemberConfMaterialDO> selectPage(MemberConfMaterialPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MemberConfMaterialDO>()
                .eqIfPresent(MemberConfMaterialDO::getMemberConfId, reqVO.getMemberConfId())
                .eqIfPresent(MemberConfMaterialDO::getPolicyType, reqVO.getPolicyType())
                .eqIfPresent(MemberConfMaterialDO::getMetalType, reqVO.getMetalType())
                .eqIfPresent(MemberConfMaterialDO::getDepositWeight, reqVO.getDepositWeight())
                .eqIfPresent(MemberConfMaterialDO::getWeightSingleLimit, reqVO.getWeightSingleLimit())
                .eqIfPresent(MemberConfMaterialDO::getWeightTotalLimit, reqVO.getWeightTotalLimit())
                .eqIfPresent(MemberConfMaterialDO::getDelayFee, reqVO.getDelayFee())
                .eqIfPresent(MemberConfMaterialDO::getProcessingFee, reqVO.getProcessingFee())
                .eqIfPresent(MemberConfMaterialDO::getAdditionalFee, reqVO.getAdditionalFee())
                .eqIfPresent(MemberConfMaterialDO::getInterestFreeDays, reqVO.getInterestFreeDays())
                .eqIfPresent(MemberConfMaterialDO::getAllowSmallOrder, reqVO.getAllowSmallOrder())
                .eqIfPresent(MemberConfMaterialDO::getAuditDepositRatio, reqVO.getAuditDepositRatio())
                .orderByDesc(MemberConfMaterialDO::getId));
    }

    default List<MemberConfMaterialDO> selectListByMemberConfId(Long memberConfId) {
        return selectList(MemberConfMaterialDO::getMemberConfId,memberConfId);
    }

    default void deleteByMemberConfId(Long memberConfId) {
        delete(MemberConfMaterialDO::getMemberConfId, memberConfId);
    }
}